
using System;

namespace finlasku
{
	
	
	public class InvoiceManagerImpl : IInvoiceManager
	{

		#region IInvoiceManager implementation
		public decimal CalculateRow (decimal amount, decimal unitprice)
		{
			return amount * unitprice;
		}
		
		public decimal CalculateSubTotal (System.Collections.Generic.IList<InvoiceRow> invoicerow)
		{
			decimal total = 0;
			foreach(InvoiceRow row in invoicerow) {
				total += row.TaxFreePrice;
			}
			return total;
		}
		
		public decimal CalculateVat (System.Collections.Generic.IList<InvoiceRow> invoicerow)
		{
			decimal vat = 0;
			foreach(InvoiceRow row in invoicerow) {
				vat += row.TaxFreePrice * ((row.TaxPercent/100)+1);
			}
			return vat;
		}
		
		public decimal CalculateTotal (decimal subtotal, decimal vat)
		{
			return subtotal + vat;
		}
		#endregion
		
		public InvoiceManagerImpl()
		{
		}
	}
}
